package com.bailian.spring.ioc.anno_dl;

import com.bailian.spring.ioc.anno_dl.bean.Cat;
import com.bailian.spring.ioc.anno_dl.bean.Person;
import com.bailian.spring.ioc.anno_dl.bean.Student;
import com.bailian.spring.ioc.anno_dl.bean2.Role;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author gaoxu
 * date: Created on 2021/10/29 上午10:03
 */
public class AnnoConfigApplicationContext {

    public static void main(String[] args) {
        /**
         * 方式1:使用配置类,完成
         */
       //ApplicationContext ctx = new AnnotationConfigApplicationContext(QuickstartConfiguration.class);

        /**
         * 方式2:直接传参一个需要扫描的包
         */
        ApplicationContext ctx = new AnnotationConfigApplicationContext("com.bailian.spring.ioc.anno_dl");

        Person person = ctx.getBean(Person.class);
        System.out.println(person);

        Cat cat = ctx.getBean(Cat.class);
        System.out.println(cat);

        Student student = ctx.getBean(Student.class);
        System.out.println(student);

        Role role = ctx.getBean(Role.class);
        System.out.println(role);
    }
}

